<?php

class crumb {

	function addCrumb($level, $title, $url, $post = false) {
		
		$tstr = "";
		
		if (isset($_SESSION['crumbs'][$level])){
			unset($_SESSION['crumbs'][$level]);
		}
		
		if($post){
			if(strpos($url,"?")){
				$tstr = "&";
			}else{
				$tstr = "?";
			}
			
			foreach($_POST as $key => $value) {
				$tstr.=$key."=".urlencode($value)."&";
			}
			$tstr = rtrim ($tstr, "&");		
		}
		
		
		$tmp = array("title" => $title, "url" => $url . $tstr);
		$_SESSION['crumbs'][$level] = $tmp;
	} 
	
	
	
	function delCrumb($level) {		
		if (isset($_SESSION['crumbs'][$level])){
			unset($_SESSION['crumbs'][$level]);
		}
	} 

	
	
	function printTrail($cur_level) {
		
		echo "<span class=\"crumb\">";			
		for ($i=1; $i != $cur_level+1; $i++){
			
			if (isset($_SESSION['crumbs'][$i])){			
				if ($i != $cur_level){
						echo "<a class=\"statusbar\" href=\"". $_SESSION['crumbs'][$i]['url'] . '">';
						echo $_SESSION['crumbs'][$i]['title'];
						echo "</a>";
				}else{
					echo '<FONT class="statusbar">' . $_SESSION['crumbs'][$i]['title'] . '</font>';	
					echo "</span>";				
				}
				if ($i != $cur_level){
					echo "<FONT class=\"statusbar\">&nbsp;&gt;&nbsp;</FONT>";
				}				
			}
		}
		echo "</span>";	
	} 
	
} 

?>
